﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Loogn.WP.Notification
{
    public class WPTileMessage
    {
        public string BackgroundImage { get; set; }
        public string Count { get; set; }
        public string Title { get; set; }

        public string ToXml()
        {
            string titleMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                    "<wp:Notification xmlns:wp=\"WPNotification\">" +
                        "<wp:Tile>";
            if (!string.IsNullOrEmpty(BackgroundImage))
            {
                titleMessage += "<wp:BackgroundImage>" + BackgroundImage + "</wp:BackgroundImage>";
            }
            if (!string.IsNullOrEmpty(Count))
            {
                titleMessage += "<wp:Count>" + Count + "</wp:Count>";
            }
            if (!string.IsNullOrEmpty(Title))
            {
                titleMessage += "<wp:Title>" + XmlEncoding.Encoding(Title) + "</wp:Title>";
            }
            titleMessage += "</wp:Tile>" +
                   "</wp:Notification>";
            return titleMessage;
        }

        public byte[] ToBytes()
        {
            var xml = ToXml();
            return Encoding.UTF8.GetBytes(xml);
        }
    }
}